﻿
using System;
using System.Collections.Generic;
using MiniWeb.Core.Dtos;
using MiniWeb.Core.Entities;
using MiniWeb.Core.Enums;
using MiniWeb.Dao;
using MiniWeb.Core.Entities;
using WFramework.Common;
using WFramework.MvcPager;

namespace MiniWeb.Task
{
    public class WebLoginLogTask
    {
        private readonly WebLoginLogDao _dao = new WebLoginLogDao();
        public PagedList<WebLoginLog> GetPagedList(int pageIndex, int pageSize)
        {
            return _dao.GetPagedList(pageIndex, pageSize);
        }


        public void CreateLog(string account,LoginTypeEnum logintype)
        {
            _dao.Add(new WebLoginLog
                         {
                             Account = account,
                             LoginTime = DateTime.Now,
                             LoginIP = DNTRequest.GetIP(),
                             LoginType = (int) logintype,
                         });
           
        }
         
        public WebLoginLog GetById(int id)
        {
            return _dao.GetById(id);
        }

        public void Delete(int id)
        {

            _dao.Delete(id);
        }


        public bool Exists(int id)
        {

            return _dao.Exists(id);
        }

        public void Add(WebLoginLog model)
        {

            _dao.Add(model);
        }

        public void Update(WebLoginLog model)
        {

            _dao.Update(model);
        }

        public List<WebLoginLog> GetAll(int? top, string strwhere)
        {
            return _dao.GetAll(top, strwhere);
        }



    }
}